<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../00-source/jquery.min.js"></script>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        html,body{
            width: 100%;
            height: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
        }
        ul{
            list-style: none;
        }
        ul>li{
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: larger;
            color: black;
        }
        .tabs{
            width: 60%;
            height: 10%;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        .tabs>li{
            width: 20%;
            height: 100%;
            border: 1px solid black;
        }
        .contents{
            width: 60%;
            height: 50%;
            position: relative;
        }
        .contents>li{
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            border: 1px solid black;
            display: none;
        }

        .contents>.active,.tabs>.active{
            background-color: red;
            display: flex;
        }
    </style>
</head>
<body>
    <ul class="tabs">
        <li class="active">1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
        <li>5</li>
    </ul>
    <ul class="contents">
        <li class="active">1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
        <li>5</li>
    </ul>
    <script>
        $('.tabs').on('click','li',function(){
            $(this).addClass('active').siblings().removeClass()

            $('.contents li').removeClass().eq($(this).index()).addClass('active')
        })

        // 其实jQuery中还有一个trigger方法，可以用来模拟事件的触发.这样就相当于有个人帮我们点击了选项卡的第四个
        $('.tabs li').eq(3).trigger('click')
    </script>
</body>
</html>